<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Kowcore
 * @copyright  Copyright KEENONWEB LLC
 * @license    http://www.keenonweb.com/
 * @version    $Id: Core.php 2011-03-09 08:45:41Z idris $
 * @author     Idris
 */

/**
 * @category   Application_Extensions
 * @package    Kowcore
 * @copyright  Copyright KEENONWEB LLC
 * @license    http://www.keenonweb.com/
 */

class Kowcore_Plugin_Core {
	public function onItemDeleteBefore($event) {
		$item = $event->getPayload ();
		
		Engine_Api::_ ()->getDbtable ( 'rates', 'kowcore' )->delete ( array ('object_type = ?' => $item->getType (), 'object_id = ?' => $item->getIdentity () ) );
	}
	
	public function onRenderLayoutDefault($event) {
		$view = $event->getPayload ();
		if ($view instanceof Zend_View) {
			$view->headScript ()->appendFile ( 'application/modules/Kowcore/externals/scripts/core.js' );
			
			if (Engine_Api::_ ()->getApi ( 'settings', 'core' )->getSetting ( 'kowcore.tips', 1 )) {
				$script = 'en4.core.runonce.add(function(){en4.kowcore.tipsObject = new en4.kowcore.tips();});';
				$view->headScript ()->appendScript ( $script );
			}
		}
	}
	
	public function onRenderLayoutDefaultSimple($event) {
		$view = $event->getPayload ();
		if ($view instanceof Zend_View) {
			$view->headScript ()->appendFile ( 'application/modules/Kowcore/externals/scripts/core.js' );
			
			if (Engine_Api::_ ()->getApi ( 'settings', 'core' )->getSetting ( 'kowcore.tips', 1 )) {
				$script = 'en4.core.runonce.add(function(){en4.kowcore.tipsObject = new en4.kowcore.tips();});';
				$view->headScript ()->appendScript ( $script );
			}
		}
	}

}